import java.io.*;
import java.util.*;

public class Main {
	BufferedReader bf;
	StringTokenizer st;
	StringBuilder sb = new StringBuilder();
	
	int a = 0, b = 0, c = 0, d = 0;
	String operator = null;	
	int real = 0, imaginary = 0;
	
	public static void main(String[] args) {		
		Main main = new Main();
		main.beginProcess();
	}

	public void beginProcess() {
		bf = new BufferedReader(new InputStreamReader(System.in));
		int n = 0;		
		
		try {
			st = new StringTokenizer(bf.readLine());
			n = Integer.parseInt(st.nextToken());
			
			while(n > 0) {				
				st = new StringTokenizer(bf.readLine());
				operator = st.nextToken();
				a = Integer.parseInt(st.nextToken());
				b = Integer.parseInt(st.nextToken());
				c = Integer.parseInt(st.nextToken());
				d = Integer.parseInt(st.nextToken());
				
				real = 0;
				imaginary = 0;
				
				getResult();
				
				n--;
			}

			System.out.print(sb);
		}
		catch(Exception ex) {
			System.err.println(ex.toString());
		}
	}
	
	private void getResult() {
		if(operator.equals("+")) {
			real = a + c;
			imaginary = b + d;
		}
		else if(operator.equals("-")) {
			real = a - c;
			imaginary = b - d;
		}
		else {
			real = (a * c) - (b * d);
			imaginary = (b * c) + (a * d);
		}
		
		sb.append(real + " " + imaginary + "\n");
	}
	
}